home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!wupost!waikato.ac.nz!ccc_spt
- From: ccc_spt@waikato.ac.nz (Simon Travaglia)
- Newsgroups: vmsnet.sources.games
- Subject: CHASE_GAME.COM - Basic car game
- Message-ID: <1992Jan28.172522.6341@waikato.ac.nz>
- Date: 28 Jan 92 17:25:22 +1300
- Organization: University of Waikato Computer Centre
- Lines: 1189
-
-
- Ok, this is a simple car game to run on a vax machine. I wrote it about 2
- years ago or so, but seeing as how there's stuff all games being posted, I
- thought I might put it on for laughs.
-
- Basically the game involves you driving round a track avoiding various
- obstacles etc.
-
- Nothing fantastic, but I think it works.
-
- The file below is a self-extracting command file - just chuck it in a
- directory somewhere called CHASE_GAME.COM then simply @CHASE_GAME. This
- will extract the game into about 7 files or so from memory...
-
- Once the extract has taken place, you can compile the source code by hand
- or by:
-
- $ @CHASE
-
- which is one of the files that was sent along with the distribution.
-
- Now - caveats:
- Don't execute this command procedure in SYSTEM or any other account
- that has privilege. (It won't do any harm, but it's just a bad
- habit to get into)
-
- It's a cheap, nasty game, don't expect bells and whistles.
-
- Have some fun.
-
- - Simon
-
- $!--CUT-HERE----------------------------------------------------------
- $ Copy SYS$INPUT: CHASE.COM
- $ Deck
- $
- $ PASC/ENV TOPTENMDL ! The File with high_score routine
- $ PAS CHASE ! The Game Source
- $ LINK CHASE,TOPTENMDL ! Link it and bob's your aunty!
- $ EOD
- $ Write Sys$output "Extracted CHASE.COM..."
- $ Copy SYS$INPUT: CHASE.CRS
- $ Deck
- +++++------------------------------+++++
- +++/ a # \+++
- ++/ # a \++
- +/ a # \+
- + a # +
- ] +------------------+ [
- ] [[----------------]] [
- ] [[__VAX_SPEEDWAY__]] [
- ] [[__S._TRAVAGLIA__]] # [
- ] [[__WAIKATO_UNIV__]] # [
- ] # [[__22-23/8/1988__]] [
- ] # [[____Q_=_QUIT____]] [
- ] # [[----------------]] [
- ] +------------------+ [
- + # a +
- +\ a # /+
- ++\ # a /++
- +++\ a /+++
- +++++------------------------------+++++
- $ EOD
- $ Write Sys$output "Extracted CHASE.CRS..."
- $ Copy SYS$INPUT: CHASE.DRN
- $ Deck
- +------------------------------+
- /Vvvv v <<<<<<\
- /Vvv v ,,,,,<\
- /Vvv v , ,,<\
- +Vv v v , ,<+
- | +------------------+ |
- | | | |
- | | | |
- | | | |
- | | | |
- | | | |
- | | | |
- | | | |
- | +------------------+ |
- +>.. . . 6 6^+
- \>... . 6 66^/
- \>..... 6 66^/
- \>>>>>> 6 666^/
- +------------------------------+
- $ EOD
- $ Write Sys$output "Extracted CHASE.DRN..."
- $ Copy SYS$INPUT: CHASE.HLP
- $ Deck
- HWelcome to Vax Speedway.
-
- You are the owner of a fully reworked Fiat Bambina with optional body extras,
- making you quite a mean force on the race track. Unfortunately, the other
- drivers are also mean forces and also a little on the dozy side.
-
- Here, at the race of the century, you are to do battle with the other drivers
- and, using your extra special keypad controls, win. (Sounds pretty simple
- really)
- #3 Your Keypad
- #4 Your Keypad
- Up
- +---+
- | 8 | Q = Quit
- +---+ +---+ +---+ ^W = Rewrite the screen
- Left | 4 | | 6 | Right
- +---+ +---+ +---+
- | 2 |
- +---+
- Down
-
- Hit Return for more info...
- [RET]
- What means what:
-
- * - You
- # - Oil spot (You lose control temporarily)
-
- 0 - Pothole (Causes fatal steering failure)
- 1, 2, 3, 4, 5 - The other maniacs (Drivers)
- ], [, -, +, /, \ - The barriers (You guessed it, deadly as well)
-
- (0a(B - Track halfway lines
- (0`(B - Raceway Official.
-
- As you may have guessed, Oil spots aren't too bad, but running into any
- of the other cars, potholes, barriers or Raceway Officials is Bad News. In
- fact, it puts you out of the race. The worst thing about oil spots and pot-
- holes is that they multiply with time, and of course, Raceway Officials are
- notorious for popping up all over the place when you least expect them......
-
-
- [Hit Return to Play]
- $ EOD
- $ Write Sys$output "Extracted CHASE.HLP..."
- $ Copy SYS$INPUT: CHASE.PAS
- $ Deck
- {
- Always make sure a copy of toptenmdl.pas goes with this
- program, as it requires it for the top ten routine.
-
- @@@ @@@ @@ @@@ @@@@@@@ @@@
- @@@@ @@@@ @@ @@ @@ @@
- @@ @@ @@ @@ @@@@@ @@ @@ @@ @@@@@ @@ @@@@ @@ @@ @@
- @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@ @@ @@@ @@
- @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@@@ @@ @@ @@
- @@ @@ @@@@@@ @@ @@ @@ @@@@@@ @@ @@ @@ @@
- @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
- @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
- @@ @@ @@@@@ @@@@@ @@ @@@@@ @@ @@ @@@@@ @@
-
-
- @@@@ @@@@ @@@ @@@@ @ @ @@@ @@@@@ @ @@@ @ @ @@@
- @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @
- @@@@ @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@@@@
- @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @
- @ @ @ @@@ @@@@ @@@ @@@ @ @ @@@ @ @ @@@
-
-
- @@@@ @@@@ @@@@@ @@@ @@@@@ @ @ @@@@@ @@@
- @ @ @ @ @ @ @ @@ @ @ @ @
- @@@@ @@@@ @@@@ @@@@@ @@@@ @ @ @ @ @@@@@
- @ @ @ @ @ @ @ @@ @ @ @
- @ @ @ @@@@@ @@@ @@@@@ @ @ @ @@@
-
-
- ***** * * ***** ***** ******
- * * * * * * * *
- * * * * * * *
- * ******* ******* ***** ****
- * * * * * * *
- * * * * * * * *
- ***** * * * * ***** ******
-
- PASC/ENV TOPTENMDL The File with high_score routine
- PAS CHASE The Game Source
- LINK CHASE,TOPTENMDL Link it and bob's your aunty!
-
- }
-
- [inherit ('sys$library:starlet',
- 'toptenmdl' ) ]
-
- Program game_name( Input, output, infile, help_file, outfile, screen_file );
-
- CONST clear_screen = ''(27)'[2J';
- home = ''(27)'[H';
- esc = chr(27);
- wide = ''(27)'#6'; {double width vt100 chars}
- bell = chr(7);
- bright = ''(27)'[1m';
- flash = ''(27)'[5m';
- clear_eol = ''(27)'[K';
- dull = ''(27)'[m';
- grafix_on = ''(27)'(0';
- grafix_off = ''(27)'(B';
- errorplace = ''(27)'[23;1H'+grafix_off;
- bs = chr(8);
- nullit = chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0);
- line_22 = ''(27)'[22;1H';
- line_23 = ''(27)'[23;1H';
- cursor_off = ''(27)'[?25l';
- cursor_on = ''(27)'[?25h';
-
- official_char = '`'; {What an official looks like. Remember to change in the HELP}
- Dead_chars = official_char+'[]/\-+12345'; {Characters you die if you touch}
- max_officials = 3; {Maximum number of officials allowed on the track}
-
- Screen_width = 40; {How many columns the game screen takes up}
- screen_depth = 20; {How many rows the game screen takes up}
- filename_length = 256; {Length of VMS filename (max) }
- input_line_length = 132; { max length of line input from a file }
-
-
- TYPE Screen_lines = packed array [1..screen_width] of char;
- filename_type = varying [filename_length] of char;
- five_str = varying [5] of char;
- ten_str = varying [10] of char;
- $uword = [WORD] 0..65535;
- $deftyp = [UNSAFE] INTEGER;
- $defptr = [UNSAFE] ^$DEFTYP;
- quad_word = [quad, unsafe] record { Defn for the schedule wakeup time vars }
- long1 : unsigned;
- long2 : integer;
- end;
- object_rec = record
- x : integer; {x_pos}
- y : integer; {y_pos}
- xi : integer; {X increment By using the x increment and the Y increment, I can}
- yi : integer; {Y increment tell which way the car is going. Should only be H or V}
- c : char; {character the car is on}
- end; {record}
- moves = array ['2'..'8'] of integer;
-
- VAR infile, outfile, help_file, screen_file : text;
- Screen : array [0..screen_depth] of screen_lines;
- dir_Screen : array [0..screen_depth] of screen_lines;
- Game_over : boolean := false;
- seed : real;
- Io_chan : [volatile] integer;
- sleep_time : quad_word; { Sleep Time}
-
- car : array [1..5] of object_rec;
- my_car : object_rec;
- official : array [1..max_officials] of object_rec;
-
- x_i : moves := ( 0, 2, -1, 2, 1, 2, 0 ); {These arrays are which way the car will move with a}
- y_i : moves := ( 1, 2, 0, 2, 0, 2, -1 ); {give key press (x and y increment values)}
-
- move_text : varying [512] of char; {The text that is passed to QIO_Write for each move cycle}
- old_y : integer := 3; {Used to stop back and forward over finish line to inc laps}
- laps : real := 0; {Number of laps the car has done}
- time_out : packed array [1..11] of char; {The current system time}
- pothole : boolean := false; {Have I hit a pothole?}
- score : integer :=0;
-
- officials_out : boolean := false; {are officials allowed on the track yet?}
- potholes_out : boolean := false; {has the track developed potholes}
-
- image_dir : varying [250] of char;
- begin_clock : integer;
- end_clock : integer;
- safe_dist : integer := 10;
- crash_char : char := ' ';
- message : varying [80] of char; {what happened death message}
-
- Iosb : {I/O Status Block}
- [volatile, Quad] Record
- Status : $uword;
- Nrbytes : $uword;
- Devdepend : $deftyp
- End {Record};
-
- char_in : integer;
- car_num : integer;
- call_status : integer;
- num_of_cars : integer := 3;
- num_of_officials : integer := 2;
-
- [ASYNCHRONOUS, EXTERNAL(lib$signal)] PROCEDURE lib$signal
- (
- %IMMED condition_value : [LIST] $deftyp
- );
- EXTERNAL;
-
- {*****************************************************************}
- procedure check_status( input_status : integer );
- begin
- if not odd( input_status ) then lib$signal( input_status );
- end;
-
- {*****************************************************************}
-
- function within( num, lower, upper : integer): boolean;
- begin
- within := (num >= lower) and (num <= upper);
- end;
-
- {*****************************************************************}
-
- Procedure image_dr;
-
- VAR image_out : varying [256] of char;
- brac_place : integer;
- rev_index : integer;
- Itemlist :
- Record
- Item : [Long(3)] Record
- Bufsize : $uword;
- Code : $uword;
- Bufadr : integer;
- Lenadr : integer
- End {Record};
- No_more : integer {set to zero to mark end of list}
- End {Record};
-
- BEGIN
- With itemlist do
- Begin
- With item do
- Begin
- Bufsize := 256;
- Code := jpi$_imagname;
- Bufadr := iaddress(image_out.body);
- Lenadr := iaddress(image_out.length);
- End {With};
- No_more := 0 { indicates end of list }
- End {With};
- $Getjpi( itmlst := itemlist);
- brac_place := image_out.length;
- While image_out[brac_place] <> ']' do brac_place := brac_place -1;
- image_dir := substr( image_out, 1, brac_place );
- END;
-
- {*****************************************************************}
- [asynchronous] function qio_write( x_in, y_in : integer; op_text: varying [l1] of char := chr(0) ) : integer;
- var x, y : varying [20] of char;
- out_text : varying [512] of char;
- begin
- $fao( ctrstr := '!UL', outbuf := y.body, outlen := y.length, p1 := y_in );
- $fao( ctrstr := '!UL', outbuf := x.body, outlen := x.length, p1 := x_in );
- out_text := esc + '[' + y + ';' + x + 'H' + op_text;
- qio_write := $qiow( chan := io_chan, func := Io$_writevblk ,
- p1 := %ref out_text.body, p2 := out_text.length );
- end;
-
- {*****************************************************************}
-
- Function get_1_char_now : integer; {Get one character IMMEDIATELY from keyboard. No char, return -1 }
- VAR char_read : char;
- begin
- call_status := $qiow( chan := IO_chan,
- iosb := iosb,
- func := io$_readvblk + io$m_noecho + io$m_nofiltr + io$m_timed,
- p1 := char_read, p2 := 1, p3 := 0 );
- check_status( call_status );
- get_1_char_now := ord(char_read);
- if iosb.status = ss$_timeout then get_1_char_now := -1
- else check_status( iosb.status );
- end; {get_1_char_now}
-
- {*****************************************************************}
-
- Function get_1_char : integer; {Get one character from the keyboard. Wait if neccessary }
- VAR char_read : char;
- begin
- call_status := $qiow( chan := IO_chan,
- iosb := iosb,
- func := io$_readvblk + io$m_noecho + io$m_nofiltr,
- p1 := char_read, p2 := 1 );
- check_status( call_status );
- check_status( iosb.status );
- get_1_char := ord(char_read);
- end; {get_1_char_now}
-
- {*****************************************************************}
- procedure sleep; { Do sleep of current sleep length }
- begin
- $schdwk( daytim := sleep_time );
- $hiber;
- end;
-
- {*****************************************************************}
-
- procedure explode( x, y : integer );
- begin
- qio_write( x, y, '@'+nullit+bs+bs+bs+'---' );
- sleep;
- qio_write( x, y, bs+'=*=' );
- sleep;
- qio_write( x, y, bs+'***' );
- sleep;
- if within( y, 1, 18) then
- begin
- qio_write( x, y-1, bs+ '\ /' );
- qio_write( x, y+1, bs+ '/ \' );
- qio_write( x, y, bs+' ' );
- sleep;
- qio_write( x, y-1, bs+ '` ~' );
- qio_write( x, y+1, bs+ ', .' );
- sleep;
- qio_write( x, y-1, bs+ ' ' );
- qio_write( x, y+1, bs+ ' ' );
- end;
- sleep;
- qio_write( x, y, bs+' ' );
- end;
-
- {************************************************************}
-
- Function random( number : integer):integer; {Give random number between 1 and number}
- {sub}function mth$random( var seed:real):real;extern;
- BEGIN
- Random := trunc(mth$random(seed)*number)+1;
- END; {random}
-
-
- {*****************************************************************}
-
- Function ok_to_put( x, y : integer ): boolean;
- begin
- ok_to_put := ( (abs(x-my_car.x) > safe_dist) and
- (abs(y-my_car.y) > safe_dist ) and
- (screen[y, x] = ' ') )
- end;
-
- {*****************************************************************}
-
- function cvt_to_chars( num :integer ): five_str; {Converts a number to a string (for concatenation}
- var chars_out : five_str;
- begin
- $fao( ctrstr := '!UL', outbuf := chars_out.body, outlen := chars_out.length, p1 := num );
- cvt_to_chars := chars_out;
- end;
-
- {*****************************************************************}
- function watton( x, y : integer): char;
- begin
- watton := dir_screen[y, x];
- end;
-
- {*****************************************************************}
- function wattons( x, y : integer): char;
- begin
- wattons := screen[y, x];
- end;
-
- {******************************************************************}
- function dead:boolean;
- begin
- dead := (index( ' '+dead_chars, screen[my_car.y, my_car.x]) > 2 );
- end;
-
- {*****************************************************************}
-
- function Put_Character( x, y :integer;
- what : char ): ten_str; {Place character}
- begin
- put_character := esc+'['+cvt_to_chars(y)+';'+cvt_to_chars(x)+'H'+what;
- end;
-
- {*****************************************************************}
-
- Function Unput_Character( x, y : integer):ten_str; {Erase character and put screen}
- begin
- unput_character := esc+'['+cvt_to_chars(y)+';'+cvt_to_chars(x)+'H'+screen[y, x];
- end;
-
- {*****************************************************************}
-
- procedure Type_file( file_to_type : filename_type); {Put help text on the terminal }
- VAR Input_line : varying [input_line_length] of char;
- waste : integer;
- BEGIN
- open( infile, file_to_type, history := readonly);
- reset(infile);
- while not eof( infile ) do
- Begin
- readln( infile, input_line );
- if input_line = '[RET]' then
- begin
- waste := get_1_char;
- writeln( Clear_screen, Home );
- end
- else writeln( Input_line ); {if input line <> RET}
- End;
- close( infile );
- END; {type_file }
-
- {*****************************************************************}
-
- Procedure do_screen_and_help; {Type startup screen and inquire if user wants help}
- VAR Yes_or_no : varying [10] of char;
- nothing : integer;
- begin
- Type_file( Image_dir+'Chase.SCN' );
- readln( yes_or_no ); {if person wants help/instructions }
- if yes_or_no.length > 0 then {default to not wanting help }
- begin
- if yes_or_no[1] in ['Y', 'T', 't', 'y'] then type_file( image_dir+'CHASE.HLP' ); {unless they ask for it}
- nothing := get_1_char;
- end;
- end; {do_screen_and_help}
-
- {*****************************************************************}
-
- Procedure setup_screen; { Setup the screen }
- VAR line_num : integer;
- Begin
- line_num := 0;
- Open( screen_file, image_dir+'Chase.crs', history := readonly ); {read in the screen layout file}
- reset( screen_file );
- while not eof( screen_file) do
- begin
- Line_num := line_num + 1;
- readln( screen_file, screen[line_num]);
- end;
- close( screen_file );
-
- line_num := 0;
- open( screen_file, image_dir+'Chase.drn', history := readonly ); {read in the directions file}
- reset( screen_file );
- while not eof( screen_file) do
- begin
- Line_num := line_num + 1;
- readln( screen_file, dir_screen[line_num]);
- end;
- close( screen_file );
-
- end;
-
- {*****************************************************************}
-
- Procedure Initialise_Game;
- begin
- seed := clock;
- Call_status := $assign(devnam := 'SYS$COMMAND:', chan := %ref IO_chan);
- if not odd( call_status) then
- begin
- writeln( errorplace, 'Error in assigning a channel to SYS$COMMAND...');
- lib$signal( call_status );
- end;
- end;
-
- {*****************************************************************}
-
- Procedure Rewrite_Screen;
- VAR line_num : integer;
- begin
- writeln( clear_screen, home, grafix_on, wide, screen[1] );
- for line_num := 2 to screen_depth do
- writeln( wide, screen[ line_num ] );
- writeln( grafix_off + esc + '[22;1HLaps: ', laps:3:1, ' Time: ', time_out, ', Score: ', score:5,grafix_on);
- writeln( home);
- end;
-
- {************************************************************}
- procedure move_my_car;
- VAR kb_char : char;
- ran_x, ran_y : integer;
- begin
- char_in := get_1_char_now;
- kb_char := ' ';
- if (char_in <> -1) and not pothole then kb_char := chr( char_in );
- move_text := move_text + unput_character( my_car.x, my_car.y );
- case kb_char of
- '2', '4', '6', '8' : begin {if a direction key}
- if my_car.xi <> -x_i[kb_char] then {so you can't reverse immediately}
- my_car.xi := x_i[kb_char];
- if my_car.yi <> -y_i[kb_char] then {so you can't reverse immediately}
- my_car.yi := y_i[kb_char];
- end;
- 'q', 'Q', chr(27) : begin {else if quit}
- game_over := true;
- crash_char := ' '; {so it says they quit}
- end;
- chr( 23 ) : rewrite_screen; {else if rewrite}
- otherwise;
- end; {case};
- my_car.x := my_car.x + my_car.xi; {change my increments (dirn)}
- my_car.y := my_car.y + my_car.yi;
- move_text := move_text + put_character( my_car.x, my_car.y, my_car.c ); {add it all to output string}
- case screen[my_car.y, my_car.x] of
- Official_char, '[', ']', '/', '\', '-', '+', '1', '2', '3', '4', '5' : begin
- game_over := true;
- crash_char := screen[ my_car.y, my_car.x];
- end; {deaded}
- 'a' : begin
- laps := laps + 0.5;
- if abs( old_y - my_car.y) < 8 then laps := laps - 0.5 {cheat - back and forward over finish line}
- else begin
- score := score + random( round( laps*random(40)) );
- time( time_out );
- writeln( grafix_off + esc + '[22;1HLaps: ', laps:3:1, ' Time: ', time_out, ', Score: ', score:5,grafix_on);
- ran_x := random( 38 ) + 1;
- ran_y := random(18) + 1;
- if ok_to_put(ran_x, ran_y) then {drop an oil spot}
- begin
- screen[ ran_y, ran_x] := '#'; {Update array}
- qio_write( ran_x, ran_y, '#' ); {Draw on screen}
- end;
- if potholes_out then
- begin
- ran_x := random( 38 ) + 1;
- ran_y := random(18) + 1;
- if ok_to_put( ran_x, ran_y) then {drop an oil spot}
- begin
- screen[ ran_y, ran_x] := '0'; {Update array}
- qio_write( ran_x, ran_y, '0' ); {Draw on screen}
- end;
- end; {if potholes out}
- end; {else}
- old_y := my_car.y; {So someone can't go back and forward on one spot}
- case round(laps*2) of
- 8 : begin {After the fifth lap, add another car}
- potholes_out := true; {Yes there are potholes}
- car[4].x := 17;
- car[4].y := 4;
- car[4].xi := -1;
- car[4].yi := 0;
- car[4].c := ' ';
- num_of_cars := 4;
- sleep_time.long1 := -1400000; {a little faster}
- end;
- 18 : begin {After the ninth lap, add another car}
- officials_out := true; {Officials are out and about}
- num_of_cars := 5; {All the cars are now out}
- car[5].x := 19;
- car[5].y := 5;
- car[5].xi := -1;
- car[5].yi := 0;
- car[5].c := ' ';
- sleep_time.long1 := -1200000; {A bit faster}
- end;
- 26 : begin
- sleep_time.long1 := -1000000; {A bit faster}
- safe_dist := 6; {Objects may appear this near to me}
- end;
- 34 : begin
- sleep_time.long1 := -800000; {up with the speed}
- safe_dist := 3; {Objects may appear THIS near to me}
- end;
- 48 : begin
- sleep_time.long1 := -600000; {Chopping along nicely now}
- safe_dist := 2; {If object appears, I'v got stuff all chance of missing}
- end;
- otherwise; {case laps}
- end;
- end;
- '#' : begin
- with my_car do
- begin
- if xi <> 0 then xi := (random(2)-1)*round(xi+2/abs(xi))
- else xi := (random(2)-1);
- if yi <> 0 then yi := (random(2)-1)*round(yi/abs(yi))
- else yi := (random(2)-1);
- end;
- end;
- '0' : begin
- pothole := true; {Player has had it}
- qio_write( 1, 22, bright+wide+grafix_off+flash+'Steering''s gone!!!'+bell+dull+clear_eol+grafix_on );
- end;
- ' ' :;
- otherwise writeln( errorplace, 'Huh? Ran over: ', screen[my_car.y, my_car.x] );
- end; {case}
- end;
-
- {************************************************************}
-
- procedure move_car( which_one : integer );
- VAR lucky_dip : integer;
- putchar : char;
- Begin
- with car[which_one] do
- begin
- move_text := move_text + Put_character( x, y, c);
- screen[y, x] := c;
- x := x + xi;
- y := y + yi;
- if wattons(x, y) in ['1', '2', '3', '4', '5'] then
- begin {cars never collide}
- x := x - xi;
- y := y - yi;
- end;
- case watton( x, y) of
- 'V' : begin
- xi := 0;
- yi := 1;
- end;
- 'v' : begin
- lucky_dip := random( 10 );
- if lucky_dip > 7 then
- begin
- xi := 0;
- yi := 1;
- end;
- end;
-
- '>' : begin
- xi := 1;
- yi := 0;
- end;
- '.' : begin
- lucky_dip := random( 10 );
- if lucky_dip > 7 then
- begin
- xi := 0;
- yi := 1;
- end;
- end;
-
- '6' : begin
- lucky_dip := random( 10 );
- if lucky_dip > 7 then
- begin
- xi := 0;
- yi :=-1;
- end;
- end;
-
- '^' : begin
- xi := 0;
- yi := -1;
- end;
-
- ',' : begin
- lucky_dip := random( 10 );
- if lucky_dip > 7 then
- begin
- xi := -1;
- yi := 0;
- end;
- end;
-
- '<' : begin
- xi := -1;
- yi := 0;
- end;
- ' ' : begin
- end;
- otherwise writeln( errorplace, grafix_off, 'Unexpected watton =', watton(x,y), '=, at [',x:0,';',y:0,'].',grafix_on );
- end; {case}
- c := wattons(x,y);
- screen[y, x] := chr(which_one+48);
- putchar := screen[y, x];
- move_text := move_text + put_character( x, y, putchar );
- end;
- end;
-
- {************************************************************}
-
- procedure move_officials;
- VAR off_num : integer;
- ran_x, ran_y : integer;
- begin
- IF random(100) > 80 then
- for off_num := 1 to num_of_officials do {These move rarely}
- with official[off_num] do
- begin
- if (x > 0) then {if it's been defined}
- begin
- qio_write( x, y, c); {if on screen then unput_character}
- screen[ y, x ] := c;
- end;
- ran_x := random(38) + 1; {work out new random x}
- ran_y := random(18) + 1; { and Y }
- if ok_to_put( ran_x, ran_y ) then { Check that the spot is not too near to my car and a blank place}
- begin
- x := ran_x; {If so, do the assignments}
- y := ran_Y;
- c := screen[y, x];
- screen[y, x] := official_char;
- qio_write( x, y, official_char ); {put_character}
- end;
- end;
- end;
-
- [asynchronous] function bugger_an_error( a, b : [unsafe] integer ):integer;
- begin
- qio_write( 1,1, clear_screen+home+grafix_off+'AAAAAAAAAAAAAAAAGGGGGGGGGH!!!!' );
- bugger_an_error := 0; {Make it die when it returns}
- qio_write( 1, 2, 'And here is your error message ...'); {after it returns, it will spill error msg}
- end;
-
- BEGIN { Game_Name }
- Initialise_Game;
- image_dr;
- Do_screen_and_help;
- Setup_screen;
- rewrite_screen;
-
- sleep_time.long1 := -1500000; { Set this up for correct delay = .15s}
- sleep_time.long2 := -1;
-
- official[1].x := 0;
- official[2].x := 0;
- official[3].x := 0;
-
- car[1].x := 10;
- car[1].y := 3;
- car[1].xi := -1;
- car[1].yi := 0;
- car[1].c := ' ';
-
- car[2].x := 18;
- car[2].y := 18;
- car[2].xi := 1;
- car[2].yi := 0;
- car[2].c := ' ';
-
- car[3].x := 37;
- car[3].y := 12;
- car[3].xi := 0;
- car[3].yi := -1;
- car[3].c := ' ';
-
- my_car.x := 22;
- my_car.y := 3;
- my_car.xi := -1;
- my_car.yi := 0;
- my_car.c := '*';
-
-
- begin_clock := clock;
- establish( bugger_an_error ); { Establish error handler }
- writeln( cursor_off );
-
- While not game_over do
- begin
- Move_text := '';
- for car_num := 1 to num_of_cars do
- if car[ car_num ].x <> 0 then
- move_car( car_num );
- if officials_out then move_officials;
- if dead then game_over := true; {Check}
- move_my_car;
- qio_write( 1, 1, move_text );
- sleep;
- end;
- explode( my_car.x, my_car.y );
-
- writeln( line_22, grafix_off );
-
- end_clock := clock;
- case crash_char of
- Official_char : message := 'You hit an Official!!!!';
- '[', ']', '/', '\', '-', '+' : Message := 'You hit a barrier!!';
- '1', '2', '3', '4', '5' : message := 'You hit another car!!!';
- ' ' : Message := 'Oh no!' ;
- otherwise;
- end; {case}
- writeln( cursor_on, message );
- sleep_time.long1 := -20000000; { So they can read the message }
- sleep;
- high_score( score, 'Chase', image_dir+'Chase.top' );
- END. { Game_Name }
- $ EOD
- $ Write Sys$output "Extracted CHASE.PAS..."
- $ Copy SYS$INPUT: CHASE.SCN
- $ Deck
- H(B
- H#33HVax Speedway!H#43HVax Speedway!HAnother Mauler 131 / Overlord Software Production
- 9H- 19882H(0sqqqqqqqwqqqqqqs1Hq x pr1Hrrss so0Hx0H
- 0Hoqsssssss1Hlqvqqqqq0Hx ssss9Hoooooppqqrs11Hx30Hx ooo48Hss60H
- 60Hoqs11Hx rqpoopqr (B\45H(0qpo opqs63Hr11Hx ros sor
- 31Hx43Hro s sr ssssp 12Hoooooo s s oooooooooooooo s s oooo>
- 21Hqrssrq47Hqrssrq20H(B[]
- 1H Simon Travaglia - Waikato University - 1988
-
- $ EOD
- $ Write Sys$output "Extracted CHASE.SCN..."
- $ Copy SYS$INPUT: TOPTENMDL.PAS
- $ Deck
- [ inherit ('sys$library:starlet') ]
-
- MODULE TOP_SCORE;
-
- [global] procedure high_score( my_score : integer;
- Game_name : varying [game_name_length] of char;
- Score_file : varying [Score_file_length] of char );
-
- Const Username_size = 12;
- text_length = 15;
- number_of_scores = 12;
- number_of_months = 12;
- home = ''(27)'[H';
- Clear_screen = ''(27)'[2J';
- esc = chr(27);
-
- done_better_msg = 'You''re not doing any better in ';
- Not_on_score = 'You''re not doing too good at ';
- Well_done = 'Hooray! You''re now entered in the high scores for ';
- good_stuff = 'Congratulations, you have increased your score in ';
-
- Type player_rec = record
- Score : integer;
- Month : packed array [1..3] of char;
- Username : packed array [1..username_size] of char;
- Text : varying [text_length] of char;
- games_played : integer;
- end; {rec}
- $uword = [WORD] 0..65535;
- quad_word = [quad, unsafe] record { Defn for the schedule wakeup time vars }
- long1 : unsigned;
- long2 : integer;
- end;
-
- VAR outfile : file of player_rec;
- screen_in, screen_out : text;
- Year_scores : array [1..number_of_months] of player_rec;
- Month_scores : array [1..number_of_scores] of player_rec;
- totals : player_rec;
- opened : boolean; {have I opened the score file}
- message : varying [80] of char;
- my_Username : packed array [1..12] of char;
- text_input : varying [256] of char;
- Date_String : packed array [1..11] of char;
- Null_rec : player_rec;
- current_rec : player_rec;
- ask_for_text : boolean;
- score_place : integer;
- wait_time : integer;
- sleep_time : quad_word; { Sleep Time}
- bombed_out : boolean;
-
- procedure get_username;
- VAR Itemlist :
- Record
- Item : [Long(3)] Record
- Bufsize : $uword;
- Code : $uword;
- Bufadr : integer;
- Lenadr : integer
- End {Record};
- No_more : integer {set to zero to mark end of list}
- End {Record};
-
- BEGIN
- With itemlist do
- Begin
- With item do
- Begin
- Bufsize := username_size;
- Code := jpi$_username;
- Bufadr := iaddress(my_username);
- Lenadr := 0; {Don't need a length returned}
- End {With};
- No_more := 0 { indicates end of list }
- End {With};
- $Getjpi( itmlst := itemlist);
- END;
-
- procedure write_new_file;
- VAR Rec_num : integer;
- start_date : packed array [1..11] of char;
- begin
- Writeln( Screen_out, 'Creating new score file...');
- open( outfile, Score_file, history := NEW, sharing := none );
- rewrite( outfile );
- get_username;
-
- totals.games_played := 1; {TOTAL NUMBER OF GAMES PLAYED}
- totals.username := my_username; {Put username in totals username field}
- date( start_date );
- totals.text := pad( start_date, ' ', text_length ); {Put initialisation date in date field}
- write( outfile, totals ); {Put it to the file then do the rest}
-
- for rec_num := 1 to number_of_months + number_of_scores do
- write( outfile, null_rec ); {write empty records}
- close( outfile );
- end;
-
- procedure read_scores;
- VAR Rec_num : integer;
- begin
- while not opened do
- begin
- open( outfile, Score_file, history := readonly, sharing := none, error := continue );
- case status( outfile ) of
- 3 : write_new_file;
- 0 : begin
- reset( outfile );
- read( outfile, totals );
- for rec_num := 1 to number_of_months do
- read( outfile, year_scores[ rec_num ] );
- for rec_num := 1 to number_of_scores do
- read( outfile, month_scores[ rec_num ] );
- opened := true;
- end; {0}
- 2 : begin
- Writeln( screen_out, Clear_screen, home, 'Please wait...');
- $schdwk( daytim := sleep_time );
- $hiber;
- Wait_time := Wait_time + 1;
- if wait_time > 15 then {Stuff it, we timed out, die horribly}
- begin
- Writeln( Screen_out, 'Sorry, cannot access the score file...');
- opened := true;
- bombed_out := true;
- end;
- end;
- otherwise
- begin
- writeln( Screen_out, clear_screen, home, 'Failed to open Score File, Please inform Games Supervisor' );
- opened := true;
- bombed_out := true;
- end;
- end; {case}
- end; {while not opened}
- end; {Read Scores}
-
- Procedure write_scores;
- VAR Rec_num : integer;
- Begin
- opened := false;
- close( outfile ); { do the close from read - Locks file from start of score to finish}
- while not opened do
- begin
- open( outfile, Score_file, history := old, sharing := none, error := continue );
- case status( outfile ) of
- 0 : begin
- rewrite( outfile);
- totals.games_played := totals.games_played + 1;
- write( outfile, totals );
- for rec_num := 1 to number_of_months do
- write( outfile, year_scores[ rec_num ] );
- for rec_num := 1 to number_of_scores do
- write( outfile, month_scores[ rec_num ] );
- opened := true;
- end; {status = 0}
- 2 : opened := true;
- otherwise
- begin
- writeln( Screen_out, 'Turd in a sock, there''s a problem with the score file ->', status(outfile) );
- opened := true; {so we don't loop on it all the time}
- end;
- end; {case}
- end; {while not opened}
- end; {write_scores}
-
- Procedure check_month;
- Var Month_string : packed array [1..3] of char;
- month_num : integer;
- score_num : integer;
- begin
- date( date_string );
- month_string := substr( date_string, 4, 3);
- month_string[2] := chr( ord(month_string[2]) + 32 );
- month_string[3] := chr( ord(month_string[3]) + 32 );
- current_rec.month := month_string;
- if (month_scores[1].games_played <> 0) and {if record is defined, not just blank}
- (month_scores[1].month <> month_string) then {if new month}
- begin
- for month_num := number_of_months-1 downto 1 do
- year_scores[ month_num +1 ] := year_scores[month_num]; {Move the monthly scores down one}
- year_scores[1] := month_scores[1]; {Put high score of last month in top}
- for score_num := 1 to number_of_scores do
- month_scores[score_num] := null_rec; {Clear previous month's high scores}
- end;
- end; {check month}
-
-
- Procedure Check_score;
- VAR Rec_num : integer;
- check_place : integer;
- begin
- Score_place := 0;
- check_place := 0;
- { Checks - 1. Is my score in the region of high scorers
- 2. Is my username somewhere else in the list?
- If above - ignore my score - tell me I've done better
- If below - push scores down over the top of my previous one and insert
- }
- For rec_num := number_of_scores downto 1 do
- if (my_score > month_scores[rec_num].score) then score_place := rec_num;
- if score_place <> 0 then
- begin
- get_username; {No point in doing this unless I fit in}
- for rec_num := score_place-1 downto 1 do
- if month_scores[rec_num].username = my_username then
- begin
- message := done_better_msg; {done better - no update}
- month_scores[rec_num].games_played := month_scores[rec_num].games_played + 1;
- end;
- if message.length = 0 then {if no higher score}
- begin
- current_rec.games_played := 1;
- current_rec.username := my_username;
- current_rec.score := my_score;
- current_rec.text := pad( current_rec.text, ' ', text_length );
-
- for rec_num := score_place to number_of_scores do
- if month_scores[rec_num].username = my_username then check_place := rec_num; {make c_p = my last score}
-
- if check_place = 0 then
- begin
- check_place := 12; {if no previous score}
- message := well_done;
- end
- else begin
- current_rec.games_played := month_scores[check_place].games_played + 1; {incr games played}
- current_rec.text := month_scores[check_place].text;
- current_rec.text := month_scores[check_place].text; {copy text}
- message := good_stuff;
- end;
-
- for rec_num := check_place-1 downto score_place do
- month_scores[rec_num+1] := month_scores[rec_num]; {move down old records}
- month_scores[score_place] := current_rec; {insert this curr_rec}
- Ask_for_text := true;
- end; {if message.length}
- end {if score_place <> 0}
- else Message := not_on_score; {if score_place DOES = 0}
- end; {check_score}
-
- Procedure display_scores;
- VAR Rec_num : integer;
- begin
- Writeln( screen_out, Clear_screen, Home,
- ' Long time winners of the past High scores of ', substr( date_string, 4, 8),' Tot: ', totals.games_played:0);
- writeln( screen_out, ' ----------------------------- -----------------------');
- Writeln( screen_out, ' ');
- Writeln( screen_out, 'Mth Score Username Name Score Username Name Games');
- Writeln( screen_out, ' ');
-
- for Rec_num := 1 to number_of_months do {write the MONTH scores}
- with year_scores[rec_num] do
- if score <> 0 then
- writeln( screen_out, esc, '[', rec_num+5:0, ';1H', month, ' ', score:5, ' ', username, ' ', text );
-
- for Rec_num := 1 to number_of_scores do {write this month's scores}
- with month_scores[rec_num] do
- if score <> 0 then
- writeln( screen_out, esc, '[', rec_num+5:0, ';40H', score:5, ' ', username, ' ', text, ' ', games_played:0 );
-
- writeln( screen_out, esc, '[20;1H', 'Current Score: ',my_Score:0 );
- Writeln( screen_out, message, game_name );
-
- if ask_for_text then
- begin
- if current_rec.text <> pad( '', ' ', text_length) then {If there's an old text field}
- Write( Screen_out, 'Enter your name and press <Return> [',current_rec.text,']: ' ) {prompt with old text default}
- else Write( screen_out, 'Enter your name and press <Return>: ' ); {Or just prompt}
- Readln( screen_in, Text_input, error := continue ); {Read my text}
- if text_input.length = 0 then text_input := current_rec.text; {Save old text}
- if text_input.length >= text_length then text_input.length := text_length {so no overflow}
- else text_input := pad( text_input, ' ', text_length ); {Pad to text_length}
- if text_input.length <> 0 then month_scores[score_place].text := text_input; {if any input change .text}
- end;
- end;
-
- BEGIN
- Open( screen_in, 'SYS$INPUT', history := readonly );
- Reset( screen_in );
- Open( screen_out, 'SYS$OUTPUT', history := new );
- Rewrite( Screen_out );
- sleep_time.long1 := -50000000; { Set this up to delay 5 secs}
- sleep_time.long2 := -1;
-
- opened := false;
- bombed_out := false;
- Null_rec := zero;
- current_rec := zero;
- ask_for_text := false;
- score_place := 0;
- wait_time := 0;
- Read_scores;
- if not bombed_out then {If i succeeded in opening the file}
- begin
- Check_month;
- Check_score;
- display_scores;
- Write_scores;
- end;
- END; {Procedure High_Score}
-
- END. {Module}
- $ EOD
- $ Write Sys$output "Extracted TOPTENMDL.PAS..."
- $ exit
- $!-CUT-HERE--------------------------------------------------------
-
- ______________________________________________________________________
- The Sturgeon General has determined that reading signatures can cause gross
- deformities in fish, carrots, turnips, politicians and other dumb animals
- DO NOT LOOK AT THIS SIGNATURE THROUGH A MAGNIFYING GLASS
- spt@waikato.ac.nz - Simon Travaglia, Computer Services, University of Waikato
- Fax: 064-7-838-4066 Ph: 064-7-838-4008 SM: Priv. Bag, Hamilton, New Zealand
- ----------------------------------------------------------------------
- You are only young once, but you can stay immature indefinitely.
-